 /* Copyright (C)
  * 2024 ZKLX Optoelectronic Technology Co.LTD
  * All rights reserved.
  */
 /**
  * @file cam_hik_ctrl.h
  * @brief 海康相机控制接口头文件
  * @author xuke
  * @version 1.0
  * @date 2024-04-18
  */

#ifndef _CAM_HIK_CTRL_H_
#define _CAM_HIK_CTRL_H_

/*------------------Include Files----------------------------*/
/*------------------End of Include Files---------------------*/

/*------------------Macro Definition-------------------------*/
#define CAM_CMD_MAX_LEN    128

//海康相机常用串口命令
#define HIK_CMD_DEVICERESET          "DeviceReset"          //WO, 写1复位
#define HIK_CMD_TECENABLE            "TEC_enable"           //RW, 0:Disable, 1:Enable
#define HIK_CMD_TECTEMPERATURE       "TEC_tmp_set"          //RW, 写 n = TEC_Temperature * 100
#define HIK_CMD_DEVICECLOCKFREQUENCY "DeviceClockFrequency" //WR, 0:85M, 1:70M, 2:60M
#define HIK_CMD_WIDTH                "Width"                //RW, 写 n 为开窗宽度值
#define HIK_CMD_HEIGHT               "Height"               //RW, 写 n 为开窗高度值
#define HIK_CMD_OFFSETX              "OffsetX"              //RW, 写 n 为离原点的水平像素数
#define HIK_CMD_OFFSETY              "OffsetY"              //RW, 写 n 为离原点的垂直像素数
#define HIK_CMD_REVERSEX             "ReverseX"             //RW, 0:Disable, 1:Enable
#define HIK_CMD_REVERSEY             "ReverseY"             //RW, 0:Disable, 1:Enable
#define HIK_CMD_PIXELFORMAT          "PixelFormat"          //RW, 0x01080001:Mono8, 0x01100003:Mono10, 0x01100005:Mono12, 0x02180014:RGB8, 0x01080009:BayerRG8, 0x0110000d:BayerRG10, 0x01100011:BayerRG12
#define HIK_CMD_TRIGGERMODE          "TriggerMode"          //RW, 0:Off, 64:On
#define HIK_CMD_TRIGGERSOFTWARE      "TriggerSoftware"      //WO, 写6
#define HIK_CMD_TRIGGERSOURCE        "TriggerSource+6"      //RW, 0:line0, 1:line1, 2:line2, 4:Counter0, 7:Software, 9:CC1, 11:CC2, 12:CC3, 13:CC4
#define HIK_CMD_TRIGGERACTIVATION    "TriggerActivation+6"  //RW, 0:RisingEdge, 1:FallingEdge
#define HIK_CMD_TRIGGERDELAYABSVAL   "TriggerDelayAbsVal+6" //RW, 写 0~16000000
#define HIK_CMD_TRIGGERCACHEENABLE   "TriggerCacheEnable"   //RW, 0:Disable, 1:Enable
#define HIK_CMD_EXPOSURETIME         "ExposureTime"         //RW, 写 n 为曝光时间
#define HIK_CMD_EXPOSUREAUTO         "ExposureAuto"         //RW, 写 0:off, 1:once, 2:continues
#define HIK_CMD_GAINABSVAL           "GainAbsVal"           //RW, 写 n = Gain / 0.0359 + 64
#define HIK_CMD_GAINCTRL             "GainCtrl"             //RW, 写 0:off, 1:once, 2:continues
#define HIK_CMD_BLACKLEVEL           "BlackLevel"           //RW, 写 n = 0~4095
#define HIK_CMD_BLACKLEVELCTRL       "BlackLevelCtrl"       //RW, 写 n = 0~4095
#define HIK_CMD_BALANCEWHITEAUTO     "BalanceWhiteAuto"     //RW, 写 n = 0~4095
#define HIK_CMD_SHARPNESSVAL         "SharpnessVal"         //RW, 写 n = 0~100
#define HIK_CMD_SHARPNESSCTRL        "SharpnessCtrl"        //RW, 写 0:Disable, 0x10000:Enable
#define HIK_CMD_DEVICETAPGEOMETRY    "DeviceTapGeometry"    //RW, 写 0x01010101:G_1X_1Y, 0x01020101:G_1X2_1Y, 0x01020102:G_1X2_1Y2, 0x0a0b0c0d:G_aXb_cYd
#define HIK_CMD_CLCONFIGURATION      "ClConfiguration"      //RO, 0:base, 1:medium, 2:full, 4:EightyBit
#define HIK_CMD_USERSETSAVE          "UserSetSave"          //RW, 写 1 保存
#define HIK_CMD_ACQUISITFRAMERATE    "AcquisitionFrameRate" //RW, 写 n1 或 n2, n1:写入的帧率值并同时开启使能; n2:需要设置的帧率值×10000(可直接写入，写入时关闭使能);
#define HIK_CMD_BRIGHTNESS           "Brightness"           //RW, 自动曝光目标灰度值
#define HIK_CMD_AUTOEXPOSURETIMEUPPERLIMIT    "AutoExposureTimeUpperLimit" //RW, 自动曝光时间上限
#define HIK_CMD_AUTOEXPOSURETIMELOWERLIMIT    "AutoExposureTimeLowerLimit" //RW, 自动曝光时间下限
/*------------------End of Macro Definition------------------*/

/*------------------Typedefs Definition----------------------*/
/*------------------End of Typedefs Definition---------------*/

/*------------------API Definition---------------------------*/
int cam_hik_dev_init(int speed);
int cam_hik_dev_close();
int cam_hik_write_key_val(std::string key, std::string val);
int cam_hik_read_key_val(std::string key, std::string &val);
int cam_ctrl_set_exposure_mode(uint8_t mode);
int cam_ctrl_set_gain_mode(uint8_t mdoe);
int cam_ctrl_set_exposure_time(uint16_t time);
int cam_ctrl_set_gain_val(uint16_t gain_val);
int cam_ctrl_set_trigger_mode(uint8_t mode);
int16_t cam_ctrl_get_exposure_mode();
int16_t cam_ctrl_get_exposure_time();
int16_t cam_ctrl_get_gain_val();
/*------------------End of API Definition--------------------*/


#endif /* End of _CAM_HIK_CTRL_H_ */

